# from mode.detection.server import InteractionServer
from util.protocol import Protocol
# from mode.support2 import Support2
# from mode.utils.config import Config
# from mode.utils.data_convert import reverse_data

def reverse_data(s):
    # 将字符串分组为两位一组，然后反转这些组的顺序，最后合并为一个字符串
    return ''.join(reversed([s[i:i+2] for i in range(0, len(s), 2)]))

def getConfig(apdu):
    address ="aaaaaaaaaaaa"
    if len(address) == 6 * 2:
        logi_address = "00"
        device_address = address
    elif len(address) == 7 * 2:
        logi_address = address[0:2]
        device_address = address[2:]
    else:
        return ""
    if 'A' in device_address.upper():
        address_type = "01"
    else:
        address_type = "00"
    device_address = reverse_data(device_address)
    frame698 = Protocol().set_address(device_address).set_link_user_data(apdu).set_logi_add(
        logi_address).set_address_type(address_type)
    frame_data = frame698.format_frame_string()
    # frame698.parser_frame
    print(frame_data)
    return frame_data
if __name__ == '__main__':
    getConfig("75010000001E02F6")